import request from '@/config/axios'

export type PHYSICALBASICVO = {
  id?: number | undefined
  pluginSwitch: number
  appletUrl: string
  exchangePage: string
  h5Url: string
}
export type PHYSICALVO = {
  id?: number | undefined
  userId: number
  amount: number
  expiredTime: string
  effectTime?: string
  benefits: string
}
export const PhysicalBasicApi = {
  // 保存实体卡基础设置
  setPhysicalBasic: async (data: PHYSICALBASICVO) => {
    return request.post({ url: '/application/physical-card-basic/save', data })
  },
  // 获得实体卡基础设置
  getPhysicalBasic: async () => {
    return request.get({ url: '/application/physical-card-basic/get' })
  }
}

export const PhysicalApi = {
  // 创建实体卡
  setPhysicalCard: async (data: PHYSICALVO) => {
    return request.post({ url: '/application/physical-card/create', data })
  },
  // 获得实体卡分页
  getPhysicalCardPage: async (params) => {
    return request.get({ url: '/application/physical-card/page', params })
  },
  // 获得实体卡详情
  getPhysicalCard: async (id) => {
    return request.get({ url: '/application/physical-card/get', params: { id } })
  },
  // 分页查看实体卡明细
  getPhysicalCardDetailsPage: async (params) => {
    return request.get({ url: '/application/physical-card/details/page', params })
  },
  // 删除实体卡
  delPhysicalCard: async (id) => {
    return request.delete({ url: '/application/physical-card/delete', params: { id } })
  },
  // 导出实体卡明细 Excel
  exportPhysicalCardDetailsExcel: async (batchId) => {
    return request.download({
      url: '/application/physical-card/details/export-excel',
      params: { batchId }
    }, true)
  }
}

export const PhysicalDetialApi = {
  // 创建实体卡明细
  setPhysicalCardDetail: async (data: PHYSICALVO) => {
    return request.post({ url: '/application/physical-card-detail/create', data })
  },
  // 作废实体卡明细
  putPhysicalCardInvalid: async (id) => {
    return request.put({ url: '/application/physical-card-detail/invalid', params: { id } })
  },
  // 获得实体卡明细分页
  getPhysicalCardDetailPage: async (params) => {
    return request.get({ url: '/application/physical-card-detail/page', params })
  }
}
